import 'package:enterprise_v6_app/app/components/custom_modele/custom_search_enter.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_title_chart_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/inspec/ins_task_detail_entity.dart';
import 'package:enterprise_v6_app/app/modules/task/task_all/inspec_task_page/repai_task_page/repai_task_controller.dart';

/// 补检任务
class RepairTaskPage extends StatelessWidget {
  RepairTaskPage({super.key});

  final controller = Get.put(RepairTaskController());

  ///获取条件搜索项
  Widget _getSearchConditionWidget() {
    return Row(
      children: [
        Expanded(
            child: CustomSearchEnter(
          height: 38.w,
          hintText: '输入任务名称',
          text: controller.search,
          onCallBack: (value) {
            controller.search = value;
            controller.refreshPage();
          },
        )),
        // AppGaps.hGap8,
        // _screen(),
      ],
    );
  }

  ///筛选
  Widget _screen() {
    return Container(
      width: 38.w,
      height: 38.w,
      alignment: Alignment.center,
      decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
      child: SvgPicture.asset(
        AppImages.icon_search_screen,
        width: 16.w,
      ),
    ).click(() {});
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            padding: EdgeInsets.symmetric(horizontal: 14.w),
            child: Column(
              children: [
                _getSearchConditionWidget(),
                AppGaps.vGap12,
                Expanded(
                  child: CustomEasyRefreshList<InsTaskDetailEntity>(
                    key: controller.globalKey,
                    dataLoad: (pageIndex, pageSize, {String? search}) async {
                      return controller.getListData(pageIndex, pageSize);
                    },
                    itemBuilder: (InsTaskDetailEntity item, int index) {
                      return CustomTitleChartPage(
                        title: item.troubleshootContent ?? '------',
                        titleRightWidget: Visibility(
                            child: Container(
                          margin: EdgeInsets.only(right: 16.w),
                          child: SvgPicture.asset(
                            AppImages.icon_supplementary_inspection,
                            width: 43.w,
                            height: 20.w,
                            // colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
                          ),
                        )),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              children: [
                                Text(
                                  '到期时间：',
                                  style: TextStyle(
                                    fontSize: 13.sp,
                                    height: 1.2,
                                    fontWeight: FontWeight.w400,
                                    color: const Color(0xffA5A6B5),
                                  ),
                                ),
                                Expanded(
                                    child: Text(
                                  '${item.supplementaryInspectionTime}',
                                  textAlign: TextAlign.right,
                                  style: TextStyle(
                                    fontSize: 12.sp,
                                    height: 1.2,
                                    fontWeight: FontWeight.w400,
                                    color: const Color(0xff495061),
                                  ),
                                ))
                              ],
                            ),
                            AppGaps.vGap10,
                            Text(
                              '${item.riskUnitName} / ${item.riskObjectName} / ${item.riskEventName}',
                              style: TextStyle(color: const Color(0xff495061), height: 1.2, fontWeight: FontWeight.w400, fontSize: 12.sp),
                            ),
                            AppGaps.vGap10,
                            Row(
                              children: [
                                Text(
                                  '管控措施：',
                                  style: TextStyle(color: const Color(0xffA5A6B5), height: 1.2, fontWeight: FontWeight.w400, fontSize: 12.sp),
                                ),
                                Expanded(
                                  child: Text(
                                    '${item.riskMeasureDesc}',
                                    style: TextStyle(color: const Color(0xff495061), height: 1.2, fontWeight: FontWeight.w400, fontSize: 12.sp),
                                  ),
                                )
                              ],
                            )
                          ],
                        ),
                      ).clickOnce(() {
                        controller.toDetailsPage(item.id!);
                      });
                    },
                  ),
                ),
              ],
            ),
          );
        });
  }
}
